<div>
    <h2 id="page-heading">
        <span>Employees</span>

        <button id="jh-create-entity" class="btn btn-primary float-right jh-create-entity create-employee" [routerLink]="['/employee/new']">
            <fa-icon icon="plus"></fa-icon>
            <span>
            Create a new Employee
            </span>
        </button>
    </h2>

    <jhi-alert-error></jhi-alert-error>

    <jhi-alert></jhi-alert>

    <div class="alert alert-warning" id="no-result" *ngIf="employees?.length === 0">
        <span>No employees found</span>
    </div>

    <div class="table-responsive" id="entities" *ngIf="employees && employees.length > 0">
        <table class="table table-striped" aria-describedby="page-heading">
            <thead>
                <tr jhiSort [(predicate)]="predicate" [(ascending)]="ascending" [callback]="reset.bind(this)">
                    <th scope="col"  jhiSortBy="id"><span>ID</span> <fa-icon icon="sort"></fa-icon></th>
                    <th scope="col"  jhiSortBy="firstName"><span>First Name</span> <fa-icon icon="sort"></fa-icon></th>
                    <th scope="col"  jhiSortBy="lastName"><span>Last Name</span> <fa-icon icon="sort"></fa-icon></th>
                    <th scope="col"  jhiSortBy="email"><span>Email</span> <fa-icon icon="sort"></fa-icon></th>
                    <th scope="col"  jhiSortBy="phoneNumber"><span>Phone Number</span> <fa-icon icon="sort"></fa-icon></th>
                    <th scope="col"  jhiSortBy="hireDate"><span>Hire Date</span> <fa-icon icon="sort"></fa-icon></th>
                    <th scope="col"  jhiSortBy="salary"><span>Salary</span> <fa-icon icon="sort"></fa-icon></th>
                    <th scope="col"  jhiSortBy="commissionPct"><span>Commission Pct</span> <fa-icon icon="sort"></fa-icon></th>
                    <th scope="col"  jhiSortBy="managerId"><span>Manager</span> <fa-icon icon="sort"></fa-icon></th>
                    <th scope="col"  jhiSortBy="departmentId"><span>Department</span> <fa-icon icon="sort"></fa-icon></th>
                    <th scope="col"></th>
                </tr>
            </thead>
            <tbody infinite-scroll (scrolled)="loadPage(page + 1)" [infiniteScrollDisabled]="page >= links['last']" [infiniteScrollDistance]="0">
                <tr *ngFor="let employee of employees ;trackBy: trackId">
                    <td><a [routerLink]="['/employee', employee.id, 'view']">{{ employee.id }}</a></td>
                    <td>{{ employee.firstName }}</td>
                    <td>{{ employee.lastName }}</td>
                    <td>{{ employee.email }}</td>
                    <td>{{ employee.phoneNumber }}</td>
                    <td>{{ employee.hireDate | date:'medium' }}</td>
                    <td>{{ employee.salary }}</td>
                    <td>{{ employee.commissionPct }}</td>
                    <td>
                        <div *ngIf="employee.managerId">
                            <a [routerLink]="['/employee', employee.managerId , 'view']" >{{ employee.managerId }}</a>
                        </div>
                    </td>
                    <td>
                        <div *ngIf="employee.departmentId">
                            <a [routerLink]="['/department', employee.departmentId , 'view']" >{{ employee.departmentId }}</a>
                        </div>
                    </td>
                    <td class="text-right">
                        <div class="btn-group">
                            <button type="submit"
                                    [routerLink]="['/employee', employee.id, 'view']"
                                    class="btn btn-info btn-sm">
                                <fa-icon icon="eye"></fa-icon>
                                <span class="d-none d-md-inline">View</span>
                            </button>

                            <button type="submit"
                                    [routerLink]="['/employee', employee.id, 'edit']"
                                    class="btn btn-primary btn-sm">
                                <fa-icon icon="pencil-alt"></fa-icon>
                                <span class="d-none d-md-inline">Edit</span>
                            </button>

                            <button type="submit" (click)="delete(employee)"
                                    class="btn btn-danger btn-sm">
                                <fa-icon icon="times"></fa-icon>
                                <span class="d-none d-md-inline">Delete</span>
                            </button>
                        </div>
                    </td>
                </tr>
            </tbody>
        </table>
    </div>
</div>
